package baseFx.common.mq;

import baseFx.common.EventDispatcher;

public interface MqSubscriber extends AutoCloseable {

    void declare(String queue);

    /**
     * 消息回调
     */
    EventDispatcher<MqMessage> eventReceived();

    EventDispatcher<SubscriberError> eventError();

    /**
     * 订阅指定队列的消息
     */
    void consume(String queue, String name, Object state);

    /**
     * 取消订阅指定队列的消息
     */
    void cancel(String queue, String name);

    @Override
    void close();

    default void consume(String queue, String name) {
        consume(queue, name, null);
    }
}
